package indiwood.model.service;

import indiwood.model.ForumListVO;
import indiwood.model.ForumVO;
import indiwood.model.PagingBean;
import indiwood.model.dao.ForumDAO;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

@Service
public class ForumServiceImpl implements ForumService {
	@Resource(name = "forumDAOImpl")
	private ForumDAO forumDAO;
	@Override
	public int write(ForumVO fvo) {
		return forumDAO.write(fvo);
	}
	@Override
	public ForumListVO ForumList(String pageNo) {
		if (pageNo == null || pageNo == "")
			pageNo = "1";
		List<ForumVO> list = forumDAO.ForumList(pageNo);
		int total = forumDAO.totalContent();
		PagingBean paging = new PagingBean(total, Integer.parseInt(pageNo));
		ForumListVO lvo = new ForumListVO(list, paging);
		return lvo;
	}

	
	@Override
	public void forumdelete(int no) {
		forumDAO.forumdelete(no);
	}
	@Override
	public void forumUpdate(ForumVO fvo) {
		
		forumDAO.forumUpdate(fvo);
	}
	
	@Override
	public ForumVO content(int no) {
		forumDAO.updateCount(no);
		return forumDAO.content(no);
	}
	@Override
	public ForumVO contentNoHit(int no) {
		
		return forumDAO.content(no);
	}

}
